{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Let's make matplotlib do math...maybe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "First let's import the data and remake one of the figures from the [overview](01_overview.ipynb) notebook. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "df = pd.read_csv(\"http://bit.ly/tcsv19\").dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZoAAAEICAYAAABmqDIrAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3deXxddZ3/8denaZOmSemaLukWGqAFilRIkU3KqhaRZRQFYSwjI4y/mQcigw6IjxEcmdHRUcFBtDBCGWdks2CHRQUpLVuhKdCN7umeNk26ZG+Wez+/P+5JmqY3bdrm5G7v5+PRR27OOffc75erffe7HnN3REREwtIn0QUQEZH0pqAREZFQKWhERCRUChoREQmVgkZEREKloBERkVApaEREJFQKGpFuMrONZtZoZnVmVmFmj5lZfqLLJZLsFDQiR+Zz7p4PnAFMA76b4PKExsz6JroMkh4UNCJHwd23AS8DU8zsb8xspZnVmlmZmd3adp2ZDTezF8xsr5ntNrM3zKxPcO6fzGxb8L7VZnZJcLyPmd1lZuvNbJeZPW1mQ4NzRWbmZjbTzDabWZWZ3dPh83LNbLaZ7Qn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dQ0uBD4M/l6fL93iI+qXk96gtaEREJFTqOhMRkVApaEREJFQKGhERCZWCRkREQqWgERGRUCloREQkVAoaEREJ1f8HKugd/Q/EoCEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "_ = ax.plot(np.sort(df['age']), marker='o', markersize=1)\n",
    "_ = ax.set(title='Passengers', ylabel='age')\n",
    "_ = ax.set_yticks([15,25, 55, 64])\n",
    "_ = ax.set_yticklabels(['children', 'youth', 'adults', 'seniors'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "The above figure is a expected cumulative distribution graph. It shows that most passengers are adults, but it is a bit hard to do comparisons, especially at the tales. Instead, we compute the histogram of passenger ages. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Let's make Histograms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "Here we call the histogram function. Bins = 'auto' tries to find the optimal number of bins using methods described in the numpy [histogram docs](https://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram_bin_edges.html#numpy.histogram_bin_edges). "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAM6klEQVR4nO3db4xl9V3H8fdHirZQFV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HBJasoCl6SmLHBJaup/AQN6Z7/3mtEsAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "(counts, edges, _) = ax.hist('age', bins='auto', data=df)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## Custom Bins to match our CDF"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "In our line plot, we use bins based on the census-a commonly accepted binning for ages. We can pass those bins into our histogram function via the `bins` parameter. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAQC0lEQVR4nO3df4xldXnH8fenrGLxR1yys3RlN53VrFowVuiUakkN7dZC1bD0D5ol0WwsybYNWm1q7aKJ8M8mtLXaJq0mW1hZWwrZIJZNTa10q6VNKjj8EpYV2QiFgZUdSqw/mkDBp3/M2eQ6zDAz99xhdr59vxJy7nnO99zzMLn5zHfP3HNOqgpJUlt+YqUbkCSNnuEuSQ0y3CWpQYa7JDXIcJekBq1Z6QYA1q1bV+Pj4yvdhiStKnfccceTVTU217YTItzHx8eZnJxc6TYkaVVJ8p/zbfO0jCQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDTLcJalBhrskNeiEuEJVmsv4ri+udAtapR6+6l0r3cKKc+YuSQ0y3C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UkeTnJv9xmZ7Gon3GcnyauT3Jjkm91n/W0D2z6cpJKsG8mxVus59+4WB98C3sHMVy+/DlxSVfevaGMrKMnbgR8An6uqN3W1K4EfVNUnVrK3hSTZAGyoqjuTvBK4A7gI+E1WQf9aWUkeBiaq6smB2pWcYJ+dJPuAf6uqq7tvEp5SVd9Nsgm4Gngj8HOD/x/DWs0zd29xMEtV3Qo8tdJ9DKOqjlbVnd3r7wOHmbnSWWpCklcBbweuAaiqZ6rqu93mTwEfYdbFnn2s5nCf6xYHhsHc3p/kG91pm7Ur3cxCkowDZwG3daVV1b9WRAFfTnJHd2uT406kz85rgWngs0nuSnJ1kpcnuRB4rKruGeXBVnO4L3iLAwHwGeB1wFuAo8CfrWw7LyzJK4DPAx+qqu+xyvrXijm3qs5m5k60l3WnKE+0z84a4GzgM1V1FvBD4ErgY8DHR32w1Rzu3uJgEarqiap6rqp+BPw1M6ezTkhJXsJMsF9XVTfB6upfK6eqHu+Wx4AvAOecgJ+dKWCqqo7/i/RGZsJ+M3BP93eDjcCdSX6q78FWc7h7i4NF6P5QedxvAPfNN3YlJQkz5yIPV9UnB+qron+tnO7UxiuPvwZ+DbjvRPvsVNV3gEeTvKErbQXurKr1VTVeVePM/AI4uxvby3LdFXLZrcAtDk54Sa4HzgPWJZkCrgDOS/IWZk5ZPQz89oo1+MLOBd4L3Jvk7q72UWYe9LIa+tfKOQ34wsz8gDXA31XVl5L8zQn42fkAcF03If028L7lOtCq/SqkJGl+q/m0jCRpHoa7JDXIcJekBhnuktQgw12SGmS4S1KDDHdJatD/ARH9WPZ+B4CjAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "(counts, edges, _) = ax.hist('age', bins=[0, 15,25, 55, 64], data=df)\n",
    "_ = ax.set_xticks([0, 15,25, 55, 64])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Probability density"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "By default `ax.hist` returns the number in each bin and the bin edges used.  The bin edges array is 1 longer than the counts because it is all of the left bin edges and then right edge of the last bin.  This is useful when we need to compare absolute values between data sets, but sometime we need to be able to compare the probability density instead.  In the continuous limit, probability density has the condition:\n",
    "\n",
    "$$1 = \\int_{-\\infty}^{\\infty} P(x)dx$$\n",
    "\n",
    "and in the discrete case:\n",
    "$$1 = \\sum_{n=0}^N w_n p_n$$\n",
    "\n",
    "where $w_n$ is the width of the nth bin. We set the `density` parameter to true to plot the density of the data. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD4CAYAAADlwTGnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAReklEQVR4nO3df6xfdX3H8edrVbep24BxNV1pdplpnI2ZhTWAY1mcjKUti9U/TIoRCCGpZG0Gi8lSXbLpf53xx0ZC2sDohM1AnLLRQDMkzMW4DEfBiq214w47udDBVTNwIxlW3/vjezq+Xi+957b33u+Xfp6P5OR7zud8Pt/v+9ze+331nO8555uqQpLUnp8adQGSpNEwACSpUQaAJDXKAJCkRhkAktSoV426gIU499xza3JyctRlSNIryiOPPPKdqpqY3f6KCoDJyUn2798/6jIk6RUlyX/M1e4hIElqlAEgSY0yACSpUQaAJDXKAJCkRhkAktQoA0CSGmUASFKjDABJatQr6kpg6VRM7rhvyV/j6M4rlvw1pMXmHoAkNcoAkKRGGQCS1CgDQJ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1wC8y+CDx8e7xnBHU9ZsMDo09Bhzopk2jrg34NeCrXV0HgT/p2kf+M5tV5zt46UPgkdfG4Fj717rp0Inf+zGpbR2wv/s3/Xvg7DGp67XAd4FfGGobeV1dHR9l8B+fg8BfAz+9FLV5KwhJatSZeAhIktSDASBJjTIAJKlRBoAkNcoAkKRGGQCS1CgDQJIa9X9XEPz/1+8HMwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "# only consider rows where we know the age\n",
    "(density, edges, _) = ax.hist('age', bins='auto', data=df, density=True)\n",
    "\n",
    "assert np.sum(np.diff(edges) * density) == 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## Practice:\n",
    "1. Make histogram of fares\n",
    "2. Use the bins defined in the [overview](01_overview.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "notes"
    }
   },
   "source": [
    "# Use groupby to simplify code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "notes"
    }
   },
   "source": [
    "![](../images/groupby.png?)\n",
    "source: [pandas cheatsheet](https://github.com/pandas-dev/pandas/blob/master/doc/cheatsheet/Pandas_Cheat_Sheet.pdf)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "notes"
    }
   },
   "source": [
    "Groupby is used to gather all rows that have one observation of one variable in common. For example, a `.groupby('sex')` gathers all the rows where the sex is male and puts them in one dataframe, and puts all the rows where the sex is female into a second dataframe. The next step in a groupby operation is usually to then aggregate these dataframes using some function (mean, median, etc) to get aggregate statistics for each variable (step 2 in the image above) but we can also make use of the individual dataframes. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "# only consider rows where we know the age\n",
    "for label, gdf in df.groupby('sex'):\n",
    "    ax.hist('age', bins=[0, 15,25, 55, 64], data=gdf, label=label, alpha=.5)\n",
    "_ = ax.set_xticks([0, 15,25, 55, 64])\n",
    "_ = ax.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Lets make things interactive"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "Just as in the [previous notebook](02_visual_variables.ipynb), we can link multiple graphs together via the sharex parameter."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "%matplotlib widget\n",
    "fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)\n",
    "# only consider rows where we know the age\n",
    "for label, gdf in df.groupby('sex'):\n",
    "    ax1.hist('age', bins='auto', data=gdf, label=label, alpha=.5)\n",
    "    ax2.hist('age', bins='auto', data=gdf, label=label, alpha=.5, density=True)\n",
    "\n",
    "_ = ax1.legend()\n",
    "_ = ax1.set(title='counts', ylabel='N')\n",
    "_ = ax2.set(title='density', ylabel='P', xlabel='age')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# What about bars and pies?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "The titanic dataset has a bunch of categorical variables (sex, pclass, survival) that are fairly interesting. In particular, it would be useful to plot some counts of this data so that we can get a sense of how things like the ratios of people in each class."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## Lets get counts\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "Pandas has a very useful function called `.value_counts` that returns the frequencies of each measurement of a variable in a row. Here I want to compute who survived. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1    180\n",
       "0     90\n",
       "Name: survived, dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "survived = df['survived'].value_counts()\n",
    "survived"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Let's make a pie chart!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "Pie charts show the ratios between different categories. The first argument to then pie chart is the wedge size (or data values). Like many of the other Matplotlib plotting routines, we can also pass in the colors and labels and [lots of other customizations](https://matplotlib.org/gallery/pie_and_polar_charts/pie_features.html). We access the values in the dataframe using the `.values` attribute"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOcAAADnCAYAAADl9EEgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAUP0lEQVR4nO3deZQdZZnH8e9rEgIEWZwBWRRZBkGWKLeCiIIL4gzqcWZUIoy4zXCubBFhRDkOAoogcRsIkAQpBAYwCIQBlUExAQx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2UevLSunB9JVlx9MXx2cc8NIStq5sFtf+wNDgSHp6y1vS3LmuAXYAiwhKd58ti3igvSXhRdEJHbO3Qe8SHKXytNd/r45PTF0Y7orOxi4geSk1L8DtzvnNgG5v4DePucsiHQG2YWklM0i0qocyfSTldMYT/l2EsIYk7JyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnrJyGuMpK6cxnvp/ucq+RtzkZWcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax =plt.subplots()\n",
    "_ = ax.pie(x=survived.values, \n",
    "       labels=['survived', 'died'], colors=['yellowgreen', 'black'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## Practice\n",
    "What's the ratio of men to women? Display it using a pie chart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Bar charts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "Often we don't want the ratio of categories, but the counts. To do this, we create bar charts. Matplotlib supports [many different types](https://matplotlib.org/gallery/index.html#lines-bars-and-markers) of bar charts. Here we will illustrate vertical bar charts."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "male      138\n",
       "female    132\n",
       "Name: sex, dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pclass = df['sex'].value_counts()\n",
    "pclass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "Matplotlib supports strings as first class data, so we can plot the labels directly. We use the '.index' attribute to get the categories and the '.values' attribute to obtain the values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAObklEQVR4nO3df6zdd13H8eeLFobbBLb0binr9A5swLEwp5eCYMhIQYaQdcYs6QQt2tgQxw9/EOxYZCZYnWJQ/nCYBuaaOLdUQFcwAk2BoAiDu42xdd1sQ3Erq+tFwg8lGY69/eN+R45353rvPd9z2vWz5yNZzvn+Oufd7Ntnv/n2ntNUFZKktjzlRA8gSRo/4y5JDTLuktQg4y5JDTLuktSg1Sd6AIA1a9bU9PT0iR5Dkk4qt9122zeqamrYtidE3Kenp5mdnT3RY0jSSSXJvy+2zdsyktQg4y5JDTLuktSgJeOe5Pokx5LcPWTb25NUkjUD665KcijJfUlePe6BJUlLW86V+w3AJQtXJjkXeBVw/8C684HNwAu6Y65Lsmosk0qSlm3JuFfVZ4FvDtn058A7gMFvHtsE3FxVD1fVYeAQsGEcg0qSlm+ke+5JLgW+XlV3Lth0DvDAwPKRbt2w19iWZDbJ7Nzc3ChjSJIWseK4JzkVuBp417DNQ9YN/U7hqtpZVTNVNTM1NfRn8CVJIxrlQ0zPBc4D7kwCsA64PckG5q/Uzx3Ydx3wYN8hJUkrs+K4V9VdwFmPLSf5GjBTVd9Isgf42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af/12IZfPrBySpQV65S1KDjLskNci4S1KDjLskNci4S1KDjLskNci4S1KD/hcXflHg02ss2AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "_ = ax.bar(pclass.index, pclass.values)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Practice \n",
    "How many people are in each class and how do visualize that?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "celltoolbar": "Slideshow",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
